package cn.ggcms.cms.dao.impl;

import java.util.List;

import org.hibernate.Criteria;
import org.hibernate.criterion.Criterion;
import org.hibernate.criterion.DetachedCriteria;

import cn.ggcms.cms.dao.PicturesDao;
import cn.ggcms.cms.utils.SimpleDao;
import cn.ggcms.cms.vo.Messages;
import cn.ggcms.cms.vo.Pictures;

public class PicturesImpl extends SimpleDao<Pictures> implements PicturesDao {

	public boolean doAddPictures(Pictures pictures) {
		boolean flag=false;
		try {
			int id=super.save(pictures);
			if (id!=0) {
				flag=true;
			}else {
				flag=false;
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
		return flag;
	}

	public boolean doDeletePictures(int id) {
		boolean flag=false;
		try {
			super.delete(Pictures.class, id);
			flag=true;
		} catch (Exception e) {
			e.printStackTrace();
		}
		return flag;
	}

	public boolean doUpdatePictures(Pictures pictures) {
		boolean flag=false;
		try {
			super.update(pictures);
			flag=true;
		} catch (Exception e) {
			e.printStackTrace();
		}
		return flag;
	}

	public List<Pictures> findAllPictures() {
		return super.find(Pictures.class);
	}

	public Pictures findPicturesById(int id) {
		return super.find(Pictures.class, id);
	}

	public List<Pictures> findAllPicturesByCondition( DetachedCriteria criteria) {
	return	super.find(criteria);
		
	}

	public List<Pictures> findAllPictures(String hql) {
	
		return super.find(hql);
	}

	public List<Pictures> findPicturesByPage(String hql, int firstResult,
			int maxResults) {
		return super.setFirstResult(firstResult).setMaxResults(maxResults).find(hql);
	}

	public int getSize() {
		return super.getTotalPage(Pictures.class);
	}

}
